package com.matt.foundation.vo;

import com.matt.domain.LiveRoom;
import com.matt.domain.TeachingArea;
import lombok.Data;

import java.util.List;
import java.util.stream.Collectors;

/**
 * *******************************
 * Created by Ron.
 * form com.matt
 * on 2017/7/11
 * *******************************
 */
@Data
public class TeachingAreaPageVo {
    private String id;

    private String name;

    private String remark;

    private Integer cameraSize;

    private Boolean isPublic;

    private List<String> cameraUrls;

    public static TeachingAreaPageVo of(TeachingArea teachingArea, List<LiveRoom> liveRooms) {
        TeachingAreaPageVo vo = new TeachingAreaPageVo();
        vo.setId(teachingArea.getId());
        vo.setName(teachingArea.getName());
        vo.setRemark(teachingArea.getRemark());
        vo.setIsPublic(teachingArea.getIsPublic());
        vo.setCameraSize(teachingArea.getCameraSize());
        if(liveRooms!= null && liveRooms.size() > 0) {
            vo.setCameraUrls(liveRooms.stream().map(o -> o.getThumbUrl()).collect(Collectors.toList()));
        }
        return vo;
    }

    public static TeachingAreaPageVo of_new(TeachingArea teachingArea) {
        TeachingAreaPageVo vo = new TeachingAreaPageVo();
        vo.setId(teachingArea.getId());
        vo.setName(teachingArea.getName());
        vo.setRemark(teachingArea.getRemark());
        vo.setIsPublic(teachingArea.getIsPublic());
        return vo;
    }
}
